package com.example.springai.config;

import com.example.springai.function.HotNewsFunction;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.model.function.FunctionCallback;
import org.springframework.ai.model.function.FunctionCallbackWrapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.function.Function;

@Configuration
public class AIConfig {

    @Bean("chatClient")
    public ChatClient getChatClient(ChatClient.Builder chatClientBuilder) {
        return chatClientBuilder.defaultSystem("请用中文回答").build();
    }

    @Bean
    public FunctionCallback hotNewsFunctionInfo() {
        return FunctionCallbackWrapper.builder(new HotNewsFunction()).withName("hotNews") // (1) function name
                .withDescription("获取热点新闻") // (2) function description
                .build();
    }

}
